package org.smart4j.chapter2.service;

import org.apache.log4j.Logger;
import org.smart4j.chapter2.help.DatabaseHelper;
import org.smart4j.chapter2.model.CustomerModel;

import java.util.List;
import java.util.Map;

/**
 * Created by xj on 2016/10/27.
 */
public class CustomerService {

    private static final Logger LOGGER = Logger.getLogger(CustomerService.class);


    public List<CustomerModel> getCustomerList() {
//        Connection conn = null;
//        long id = 0;
//        PreparedStatement statement = null;
//
//        List<CustomerModel> customerModelList = new ArrayList<CustomerModel>();
        String sql = "select * from customer;";
//            // conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
//            conn = DatabaseHelper.getConnection();
//            statement = conn.prepareStatement(sql);
//            ResultSet rs = statement.executeQuery();
//            while (rs.next()) {
//                CustomerModel customerModel = new CustomerModel();
//                customerModel.setId(rs.getLong("id"));
//                customerModel.setName(rs.getString("name"));
//                customerModel.setContact(rs.getString("contact"));
//                customerModel.setTelephone(rs.getString("telephone"));
//                customerModel.setEmail(rs.getString("email"));
//                customerModel.setRemark(rs.getString("remark"));
//                customerModelList.add(customerModel);
//            }
//            if (statement != null) {
//                statement.close();
//            }
        return DatabaseHelper.queryEntitList(CustomerModel.class, sql);

    }


    public CustomerModel getCustomer(long id) {
        return null;
    }

    public boolean createCustomer(Map<String, Object> fieldMap) {

        return false;
    }

    public boolean updateCustomer(CustomerModel customer) {

        return false;
    }

    public boolean deleteCustomer(long id) {
        return false;
    }


}
